import java.applet.*;
import java.awt.event.*;
import java.awt.*;
import java.util.Random;

import javax.swing.JList;
import javax.swing.text.StyledEditorKit.ForegroundAction;

public class doublebuffering extends Applet implements MouseListener, MouseMotionListener{
	Graphics dBuf;
	Image offscreen;
	Dimension d;
	int x,y;
	int [] numSorteados;
	String [] words = {"CABECA", "ALFABETO", "JUNTA", "ALFACE"};
	String [] alfabeto = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
	String [][] matriz;
	String [] palavrasSorteadas;
	JList listaPalavrasSorteadas = new JList();
	Random numRandom = new Random();
	
	public void init()
	{
		for(int i=0; i <=5; i++)
			numSorteados[i]= numRandom.nextInt(words.length);
		/*for(int i=0; i <= 10; i++)
			for(int j=0; j <= 10 ; j++)
			{
				matriz[i][j]=Random();
			}*/
		d=getSize();
		addMouseMotionListener(this);
		addMouseListener(this);
		setBackground(Color.black);
		
		offscreen=createImage(d.width, d.height);
		dBuf=offscreen.getGraphics();
		
	}
	
	public void paint (Graphics g)
	{
		dBuf.clearRect(0, 0, d.width, d.height);
		dBuf.setColor(Color.red);
		dBuf.drawString("Mouse Mecheu", x, y);
		dBuf.fillRect(x,y,20,20);
		
		g.drawImage(offscreen, 0,0,this);
	}
	
	public void update (Graphics g)
	{
		paint(g);
	}
	@Override
	public void mouseDragged(MouseEvent e) {
		
		
	}
	@Override
	public void mouseMoved(MouseEvent e) {
		x=e.getX();
		y=e.getY();
		repaint();
		
	}
	@Override
	public void mouseClicked(MouseEvent e){
		dBuf.drawString("Mouse Clicou", 150, 150);
		repaint();
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	

}
